declare i32 @printf(i8* , ...)
declare i8* @strcat(i8* , i8* )
declare i32 @strlen(i8*)
declare double @llvm.pow.f64(double, double)
declare double @atof(i8*)
declare i32 @sprintf(i8*, i8*, ...)
declare i8* @malloc(i32)
declare void @llvm.memset.i32(i8* , i8, i32, i32)
declare i8* @strcpy(i8* , i8*)
declare i32 @strcmp(i8*, i8*)
@ftoa.str = internal constant [3 x i8] c"%f\00"
@false.str = internal constant [6 x i8] c"false\00"
@true.str = internal constant [5 x i8] c"true\00"
@global.n = common global double 0.000000e+00
@global.delta = common global double 0.000000e+00
@f.retval = common global {double} zeroinitializer
@bisect.retval = common global {double, double} zeroinitializer
@bisect.bb2.c = common global double 0.000000e+00
@string0 = constant [3 x i8] c"c=\00"
@string1 = constant [3 x i8] c"a=\00"
@string2 = constant [3 x i8] c"b=\00"
@string3 = constant [2 x i8] c"\0A\00"
@print0 = constant [26 x i8] c"%f\09%s\09%f\09%s\09%f\09%s\09%f\09%s\09\0A\00"
@bisect.bb3.fc = common global double 0.000000e+00
@solve.bb9.z = common global double 0.000000e+00
@solve.bb9.e = common global double 0.000000e+00
@string4 = constant [6 x i8] c"after\00"
@string5 = constant [15 x i8] c"steps, root is\00"
@string6 = constant [11 x i8] c"with error\00"
@string7 = constant [5 x i8] c", f=\00"
@print1 = constant [26 x i8] c"%s\09%f\09%s\09%f\09%s\09%f\09%s\09%f\09\0A\00"
define void @f(double %x) alwaysinline {
entry:
%f.x = alloca double
store double %x, double* %f.x
%retval0 = alloca double
br label %f.bb1
f.bb1:
%f.bb1.tmp6 = load double* %f.x
%f.bb1.tmp7 = load double* %f.x
%f.bb1.tmp5 = mul double %f.bb1.tmp6, %f.bb1.tmp7
%f.bb1.tmp8 = load double* %f.x
%f.bb1.tmp4 = mul double %f.bb1.tmp5, %f.bb1.tmp8
%f.bb1.tmp9 = load double* %f.x
%f.bb1.tmp3 = sub double %f.bb1.tmp4, %f.bb1.tmp9
%f.bb1.tmp2 = sub double %f.bb1.tmp3, 1.000000
store double %f.bb1.tmp2, double* %retval0
br label %return
return:
%f.return.tmp11 = load double* %retval0
%f.return.tmp12 = getelementptr {double}* @f.retval, i32 0, i32 0
store double %f.return.tmp11, double* %f.return.tmp12
ret void
}
define void @bisect(double %a, double %b, double %fa, double %fb) alwaysinline {
entry:
%bisect.a = alloca double
store double %a, double* %bisect.a
%bisect.b = alloca double
store double %b, double* %bisect.b
%bisect.fa = alloca double
store double %fa, double* %bisect.fa
%bisect.fb = alloca double
store double %fb, double* %bisect.fb
%retval0 = alloca double
%retval1 = alloca double
br label %bisect.bb2
bisect.bb2:
%bisect.bb2.tmp15 = load double* %bisect.a
%bisect.bb2.tmp16 = load double* %bisect.b
%bisect.bb2.tmp14 = add double %bisect.bb2.tmp15, %bisect.bb2.tmp16
%bisect.bb2.tmp13 = fdiv double %bisect.bb2.tmp14, 2.000000
store double %bisect.bb2.tmp13, double* @bisect.bb2.c
%bisect.bb2.tmp19 = load double* @global.n
%bisect.bb2.tmp20 = bitcast [3 x i8]* @string0 to i8*
%bisect.bb2.tmp21 = load double* @bisect.bb2.c
%bisect.bb2.tmp22 = bitcast [3 x i8]* @string1 to i8*
%bisect.bb2.tmp23 = load double* %bisect.a
%bisect.bb2.tmp24 = bitcast [3 x i8]* @string2 to i8*
%bisect.bb2.tmp25 = load double* %bisect.b
%bisect.bb2.tmp26 = bitcast [2 x i8]* @string3 to i8*
%bisect.bb2.tmp27 = bitcast [26 x i8]* @print0 to i8*
call i32 (i8*, ...)* @printf(i8* %bisect.bb2.tmp27, double %bisect.bb2.tmp19, i8* %bisect.bb2.tmp20, double %bisect.bb2.tmp21, i8* %bisect.bb2.tmp22, double %bisect.bb2.tmp23, i8* %bisect.bb2.tmp24, double %bisect.bb2.tmp25, i8* %bisect.bb2.tmp26)
%bisect.bb2.tmp31 = load double* @bisect.bb2.c
%bisect.bb2.tmp32 = load double* %bisect.a
%bisect.bb2.tmp30 = fcmp ueq double %bisect.bb2.tmp31, %bisect.bb2.tmp32
%bisect.bb2.tmp34 = load double* @bisect.bb2.c
%bisect.bb2.tmp35 = load double* %bisect.b
%bisect.bb2.tmp33 = fcmp ueq double %bisect.bb2.tmp34, %bisect.bb2.tmp35
%bisect.bb2.tmp29 = or i1 %bisect.bb2.tmp30, %bisect.bb2.tmp33
%bisect.bb2.tmp39 = load double* %bisect.a
%bisect.bb2.tmp40 = load double* %bisect.b
%bisect.bb2.tmp38 = sub double %bisect.bb2.tmp39, %bisect.bb2.tmp40
%bisect.bb2.tmp42 = load double* @global.delta
%bisect.bb2.tmp41 = sub double 0.000000e+00, %bisect.bb2.tmp42
%bisect.bb2.tmp37 = fcmp ugt double %bisect.bb2.tmp38, %bisect.bb2.tmp41
%bisect.bb2.tmp45 = load double* %bisect.a
%bisect.bb2.tmp46 = load double* %bisect.b
%bisect.bb2.tmp44 = sub double %bisect.bb2.tmp45, %bisect.bb2.tmp46
%bisect.bb2.tmp47 = load double* @global.delta
%bisect.bb2.tmp43 = fcmp ult double %bisect.bb2.tmp44, %bisect.bb2.tmp47
%bisect.bb2.tmp36 = and i1 %bisect.bb2.tmp37, %bisect.bb2.tmp43
%bisect.bb2.tmp28 = or i1 %bisect.bb2.tmp29, %bisect.bb2.tmp36
br i1 %bisect.bb2.tmp28, label %bisect.bb4, label %bisect.bb3
bisect.bb4:
%bisect.bb4.tmp48 = load double* @bisect.bb2.c
%bisect.bb4.tmp50 = load double* %bisect.b
%bisect.bb4.tmp51 = load double* %bisect.a
%bisect.bb4.tmp49 = sub double %bisect.bb4.tmp50, %bisect.bb4.tmp51
store double %bisect.bb4.tmp48, double* %retval0
store double %bisect.bb4.tmp49, double* %retval1
br label %return
br label %bisect.bb3
bisect.bb5:
br label %bisect.bb3
bisect.bb3:
%bisect.bb3.tmp53 = load double* @global.n
%bisect.bb3.tmp52 = add double %bisect.bb3.tmp53, 1.000000
store double %bisect.bb3.tmp52, double* @global.n
%bisect.bb3.tmp56 = load double* @bisect.bb2.c
call void@f(double %bisect.bb3.tmp56)
%bisect.bb3.tmp57 = load {double}* @f.retval
%bisect.bb3.tmp58 = extractvalue {double} %bisect.bb3.tmp57, 0
store double %bisect.bb3.tmp58, double* @bisect.bb3.fc
%bisect.bb3.tmp62 = load double* %bisect.fa
%bisect.bb3.tmp63 = load double* @bisect.bb3.fc
%bisect.bb3.tmp61 = mul double %bisect.bb3.tmp62, %bisect.bb3.tmp63
%bisect.bb3.tmp60 = fcmp ult double %bisect.bb3.tmp61, 0.000000
br i1 %bisect.bb3.tmp60, label %bisect.bb7, label %bisect.bb8
bisect.bb7:
%bisect.bb7.tmp65 = load double* %bisect.a
%bisect.bb7.tmp66 = load double* @bisect.bb2.c
%bisect.bb7.tmp67 = load double* %bisect.fa
%bisect.bb7.tmp68 = load double* @bisect.bb3.fc
call void@bisect(double %bisect.bb7.tmp65, double %bisect.bb7.tmp66, double %bisect.bb7.tmp67, double %bisect.bb7.tmp68)
%bisect.bb7.tmp69 = load {double, double}* @bisect.retval
%bisect.bb7.tmp70 = extractvalue {double, double} %bisect.bb7.tmp69, 0
%bisect.bb7.tmp71 = extractvalue {double, double} %bisect.bb7.tmp69, 1
store double %bisect.bb7.tmp70, double* %retval0
store double %bisect.bb7.tmp71, double* %retval1
br label %return
br label %return
bisect.bb8:
%bisect.bb8.tmp72 = load double* @bisect.bb2.c
%bisect.bb8.tmp73 = load double* %bisect.b
%bisect.bb8.tmp74 = load double* @bisect.bb3.fc
%bisect.bb8.tmp75 = load double* %bisect.fb
call void@bisect(double %bisect.bb8.tmp72, double %bisect.bb8.tmp73, double %bisect.bb8.tmp74, double %bisect.bb8.tmp75)
%bisect.bb8.tmp76 = load {double, double}* @bisect.retval
%bisect.bb8.tmp77 = extractvalue {double, double} %bisect.bb8.tmp76, 0
%bisect.bb8.tmp78 = extractvalue {double, double} %bisect.bb8.tmp76, 1
store double %bisect.bb8.tmp77, double* %retval0
store double %bisect.bb8.tmp78, double* %retval1
br label %return
br label %return
bisect.bb6:
br label %return
return:
%bisect.return.tmp79 = load double* %retval0
%bisect.return.tmp80 = getelementptr {double, double}* @bisect.retval, i32 0, i32 0
store double %bisect.return.tmp79, double* %bisect.return.tmp80
%bisect.return.tmp81 = load double* %retval1
%bisect.return.tmp82 = getelementptr {double, double}* @bisect.retval, i32 0, i32 1
store double %bisect.return.tmp81, double* %bisect.return.tmp82
ret void
}
define void @solve(double %a, double %b) alwaysinline {
entry:
%solve.a = alloca double
store double %a, double* %solve.a
%solve.b = alloca double
store double %b, double* %solve.b
br label %solve.bb9
solve.bb9:
store double 0.000000, double* @global.n
%solve.bb9.tmp85 = load double* %solve.a
%solve.bb9.tmp86 = load double* %solve.b
%solve.bb9.tmp87 = load double* %solve.a
call void@f(double %solve.bb9.tmp87)
%solve.bb9.tmp88 = load {double}* @f.retval
%solve.bb9.tmp89 = extractvalue {double} %solve.bb9.tmp88, 0
%solve.bb9.tmp90 = load double* %solve.b
call void@f(double %solve.bb9.tmp90)
%solve.bb9.tmp91 = load {double}* @f.retval
%solve.bb9.tmp92 = extractvalue {double} %solve.bb9.tmp91, 0
call void@bisect(double %solve.bb9.tmp85, double %solve.bb9.tmp86, double %solve.bb9.tmp89, double %solve.bb9.tmp92)
%solve.bb9.tmp93 = load {double, double}* @bisect.retval
%solve.bb9.tmp94 = extractvalue {double, double} %solve.bb9.tmp93, 0
%solve.bb9.tmp95 = extractvalue {double, double} %solve.bb9.tmp93, 1
store double %solve.bb9.tmp94, double* @solve.bb9.z
store double %solve.bb9.tmp95, double* @solve.bb9.e
%solve.bb9.tmp98 = bitcast [6 x i8]* @string4 to i8*
%solve.bb9.tmp99 = load double* @global.n
%solve.bb9.tmp100 = bitcast [15 x i8]* @string5 to i8*
%solve.bb9.tmp101 = load double* @solve.bb9.z
%solve.bb9.tmp102 = bitcast [11 x i8]* @string6 to i8*
%solve.bb9.tmp103 = load double* @solve.bb9.e
%solve.bb9.tmp104 = bitcast [5 x i8]* @string7 to i8*
%solve.bb9.tmp105 = load double* @solve.bb9.z
call void@f(double %solve.bb9.tmp105)
%solve.bb9.tmp106 = load {double}* @f.retval
%solve.bb9.tmp107 = extractvalue {double} %solve.bb9.tmp106, 0
%solve.bb9.tmp108 = bitcast [26 x i8]* @print1 to i8*
call i32 (i8*, ...)* @printf(i8* %solve.bb9.tmp108, i8* %solve.bb9.tmp98, double %solve.bb9.tmp99, i8* %solve.bb9.tmp100, double %solve.bb9.tmp101, i8* %solve.bb9.tmp102, double %solve.bb9.tmp103, i8* %solve.bb9.tmp104, double %solve.bb9.tmp107)
br label %return
return:
ret void
}
define i32 @main() alwaysinline {
entry:
br label %main.bb0
main.bb0:
store double 0.000001, double* @global.delta
%main.bb0.tmp109 = add double 0.000000e+00, 1.000000
%main.bb0.tmp110 = add double 0.000000e+00, 2.000000
call void@solve(double %main.bb0.tmp109, double %main.bb0.tmp110)
ret i32 0
}
define i8* @ftoa(double %num) alwaysinline {
entry:
%0 = tail call i8* @malloc(i32 256)
tail call void @llvm.memset.i32(i8* %0, i8 0, i32 256, i32 1)
%1 = tail call i32 (i8*, i8*, ...)* @sprintf(i8* %0, i8* getelementptr ([3 x i8]* @ftoa.str, i32 0, i32 0), double %num)
ret i8* %0
}
define i8* @stringcat(i8* %s1, i8* %s2) alwaysinline {
entry:
%0 = tail call i8* @malloc(i32 256)
tail call void @llvm.memset.i32(i8* %0, i8 0, i32 256, i32 1)
%1 = tail call i8* @strcpy(i8* %0, i8* %s1)
%2 = tail call i8* @strcat(i8* %0, i8* %s2)
ret i8* %0
}
define i1 @stringcmp(i8* %s1, i8* %s2, i32 %op) alwaysinline {
entry:
%0 = tail call i32 @strcmp(i8* %s1, i8* %s2)
	switch i32 %op, label %return [
i32 0, label %bb
i32 1, label %bb1
i32 2, label %bb2
i32 3, label %bb3
i32 4, label %bb4
i32 5, label %bb5
]
bb:
%1 = icmp slt i32 %0, 0
ret i1 %1
bb1:
%2 = icmp sgt i32 %0, 0
ret i1 %2
bb2:
%3 = icmp slt i32 %0, 1
ret i1 %3
bb3:
%4 = icmp sgt i32 %0, -1
ret i1 %4
bb4:
%5 = icmp ne i32 %0, 0	
ret i1 %5
bb5:
%6 = icmp eq i32 %0, 0	
ret i1 %6
return:
ret i1 undef
}
define i8* @btoa(i1 %i) alwaysinline {
entry:
        %.0 = select i1 %i, i8* getelementptr ([5 x i8]* @true.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @false.str, i32 0, i32 0)
ret i8* %.0
}
